A good answer might be:

And of course you have done this in Notepad...


Complete Program

Here is the complete program:

import java.io.*;
class AddUpAll
{
  public static void main ( String[] args ) throws IOException
  {
    int value;     // the value of the current integer
    int limit;     // the number of integers to add up
    int sum = 0;   // initialize sum

    String line;
    BufferedReader stdin = new BufferedReader( 
        new InputStreamReader( System.in ) );

    // get the number of integers to add up
    System.out.println("Enter how many integers:");
    line   = stdin.readLine();
    limit  = Integer.parseInt( line.trim() );

    int count = 1; // initialize count

    while ( count <= limit )
    {
      System.out.println("Enter a number:");
      line   = stdin.readLine();
      value  = Integer.parseInt( line.trim() );
      sum    = sum + value; // add to the sum
      count  = count + 1;   // increment count
    }

    System.out.println( "Grand Total: " + sum );
  }
}

The program includes user prompts so that it is easy to debug with keyboard input. A "production" version of the program would make those lines comments.

QUESTION 5:

(Review: ) What do you type at the command line prompt to run this program with the file manyNums.dat?